<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>Applies the changes made to a data graph back to the database.</title>

 </head>
 <body><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="ref.sdodasrel.html">SDO-DAS-Relational 函数</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="sdo-das-relational.construct.html">SDO_DAS_Relational::__construct</a></div>
 <div class="up"><a href="ref.sdodasrel.html">SDO-DAS-Relational 函数</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div><hr /><div id="sdo-das-relational.applychanges" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">SDO_DAS_Relational::applyChanges</h1>
  <p class="verinfo">(^)</p><p class="refpurpose"><span class="refname">SDO_DAS_Relational::applyChanges</span> &mdash; <span class="dc-title">
   Applies the changes made to a data graph back to the database.
  </span></p>

 </div>

 <div class="refsect1 description" id="refsect1-sdo-das-relational.applychanges-description">
  <h3 class="title">说明</h3>
  <div class="methodsynopsis dc-description">
   <span class="type"><span class="type void">void</span></span> 
   <span class="methodname"><strong>SDO_DAS_Relational::applyChanges</strong></span>
    ( <span class="methodparam">
    <span class="type"><a href="class.pdo.html" class="type PDO">PDO</a></span>
     <code class="parameter">$database_handle</code>
   </span>
   , <span class="methodparam">
    <span class="type"><span class="type SDODataObject">SDODataObject</span></span>
     <code class="parameter">$root_data_object</code>
   </span>
   )</div>


  <div class="warning"><strong class="warning">Warning</strong><p class="simpara">此函数是<em class="emphasis">实验性</em>的。此函数的表象，包括名称及其相关文档都可能在未来的
PHP 发布版本中未通知就被修改。使用本函数风险自担 。</p></div>

  <p class="para">
   Given a PDO database handle and the special root object of a data graph, 
   examine the change summary in the datagraph and applies the changes 
   to the database.
   The changes that it can apply can be creations of data objects, 
   deletes of data objects, and modifications to properties of data objects.
  </p>
 </div>

 
 <div class="refsect1 parameters" id="refsect1-sdo-das-relational.applychanges-parameters">
  <h3 class="title">参数</h3>
  <p class="para">
   <dl>

    
     <dt>
PDO_database_handle</dt>

     <dd>

      <p class="para">
       Constructed using the PDO extension. 
       A typical line to construct a PDO database handle might look like this:
       <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000">
$dbh&nbsp;=&nbsp;new&nbsp;PDO("mysql:dbname=COMPANYDB;host=localhost",DATABASE_USER,DATABASE_PASSWORD);</span>
</code></div>
       </div>

      </p>
     </dd>

    
    
     <dt>
root_data_object</dt>

     <dd>

      <p class="para">
       The special root object which is at the top of every SDO data graph.
      </p>
     </dd>

    
   </dl>

  </p>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-sdo-das-relational.applychanges-returnvalues">
  <h3 class="title">返回值</h3>
  <p class="para">
   None.
   Note however that the datagraph that was passed is still intact and usable.
   Furthermore, if data objects were created and written back to a 
   table with autogenerated primary keys, 
   then those primary keys will now be set in the data objects.
   If the changes were successfully written, 
   then the change summary associated with the datagraph will 
   have been cleared, 
   so that it is possible to now make further changes to the 
   data graph and apply those changes in turn.
   In this way it is possible to work with the same data graph 
   and apply changes repeatedly.
  </p>
 </div>




 <div class="refsect1 errors" id="refsect1-sdo-das-relational.applychanges-errors">
  <h3 class="title">错误／异常</h3>
  <p class="para">
   <span class="function"><strong>SDO_DAS_Relational::applyChanges()</strong></span>
   can throw an <strong class="classname">SDO_DAS_Relational_Exception</strong> if it is 
   unable to apply all the changes correctly.
  </p>
  <p class="para">
   The Relational DAS starts a database transaction before 
   beginning to apply the changes and will commit 
   the transaction only if they are all successful.
   The Relational DAS generates qualified update and delete statements 
   which contain a where clause that specifies that the row to be 
   updated or deleted must contain the same values that it did 
   when the data was first retrieved.
   This is how the optimistic concurrency is implemented.
   If any of the qualified update or delete statements fails to update or 
   delete their target row, it may be because the data has been altered 
   in the database in the meantime.
   In any event, if any update fails for any reason, 
   the transaction is rolled back and an exception thrown.
   The exception will contain the generated SQL statement that failed.
  </p>
  
  <p class="para">
   The Relational DAS also catches any PDO exceptions and obtains PDO 
   diagnostic information which it includes in an 
   <strong class="classname">SDO_DAS_Relational_Exception</strong> which it then throws.
  </p>
 </div>


 <div class="refsect1 examples" id="refsect1-sdo-das-relational.applychanges-examples">
  <h3 class="title">范例</h3>
  <p class="para">
   Please see the
   <a href="sdodasrel.examples.html" class="link">Examples</a>
   section in the general information about the Relational DAS
   for many examples of calling this method.
   Please see also the section on
   <a href="sdodasrel.configuration.html#sdodasrel.tracing" class="link">Tracing</a>
   to see how you can see what SQL statements are 
   generated by the Relational DAS.
  </p>
 </div>

</div><hr /><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="ref.sdodasrel.html">SDO-DAS-Relational 函数</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="sdo-das-relational.construct.html">SDO_DAS_Relational::__construct</a></div>
 <div class="up"><a href="ref.sdodasrel.html">SDO-DAS-Relational 函数</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div></body></html>
